<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>优惠券</title>
		 <link rel="stylesheet" href="<?php echo IMG_PATH ?>bdkd/css/common.css" />
		<link rel="stylesheet" href="<?php echo IMG_PATH ?>bdkd/css/coupon.css" />
		
	</head>
	<body>
    <input type="hidden" id="type" value="<?php echo $type; ?>">
    <input type="hidden" id="id" value="<?php
    if(isset($id) && !empty($id)){
        echo $id;
    }

    ?>">
    <input type="hidden" id="wtype" value="
    <?php
    if(isset($wtype) && !empty($wtype)){
        echo $wtype;
    }
    ?>
    ">
		
		<div class="coupon">
            <div class="valid">
                <?php

                if(!empty($list1)){
                    foreach ($list1 as $value)
                    {
                        if($value['type']==1){
                            ?>
                            <input type="hidden" class="vid" value="<?php echo $value['id'];?>">
                            <div class="stamps">
                                <div class="stamp_top">
                                    <div class="num">
                                        <p><?php echo $value['discount'];?></p>
                                        <span>元</span>
                                    </div>
                                    <div class="aging">
                                        <p>代取券</p>
                                        <span>有效期至：<?php echo date("Y-m-d",$value['end_time'])?></span>
                                    </div>
                                </div>
                                <div class="stamp_bottom">
                                    <p>仅限于&nbsp;&nbsp;"代取快递"&nbsp;&nbsp;付款时使用</p>
                                </div>
                            </div>
                            <?php
                        }else{
                            ?>
                            <input type="hidden" class="vid" value="<?php echo $value['id'];?>">
                            <div class="stamp">
                                <div class="stamp_top">
                                    <div class="num">
                                        <p><?php echo $value['discount']*10?></p>
                                        <span>折</span>
                                    </div>
                                    <div class="aging">
                                        <p>邮寄券</p>
                                        <span>有效期至：<?php echo date("Y-m-d",$value['end_time'])?></span>
                                    </div>
                                </div>
                                <div class="stamp_bottom">
                                    <p>仅限于&nbsp;&nbsp;"邮寄快递"&nbsp;&nbsp;和&nbsp;&nbsp;"物流托运"&nbsp;&nbsp;时使用</p>
                                </div>
                            </div>
                            <?php
                        }
                    }
                }
                ?>

            </div>


			<div class="vain">
				<div class="title">
					<span></span><p>以下是已经过期的优惠券</p><span></span>
				</div>
                <?php
                if(!empty($list2)){
                    foreach ($list2 as $value){
                        if($value['type']==1){
                            ?>
                            <input type="hidden" class="vid" value="<?php echo $value['id'];?>">
                            <div class="efficacy1">
                                <div class="efficacy_top">
                                    <div class="num">
                                        <p><?php echo $value['discount'];?></p>
                                        <span>元</span>
                                    </div>
                                    <div class="omit">
                                        <img src="<?php echo IMG_PATH ?>bdkd/img/icon1.png"/>
                                    </div>
                                    <div class="aging">
                                        <p>代取券</p>
                                        <span>有效期至：<?php echo date("Y-m-d",$value['end_time'])?></span>
                                    </div>
                                </div>
                                <div class="efficacy_bottom">
                                    <p>仅限于&nbsp;&nbsp;"代取快递"&nbsp;&nbsp;付款时使用</p>
                                </div>
                            </div>
                            <?php
                        }else{
                            ?>
                            <input type="hidden" class="vid" value="<?php echo $value['id'];?>">
                            <div class="efficacy">
                                <div class="efficacy_top">
                                    <div class="num">
                                        <p><?php echo $value['discount']*10?></p>
                                        <span>折</span>
                                    </div>
                                    <div class="omit">
                                        <img src="<?php echo IMG_PATH ?>bdkd/img/icon1.png"/>
                                    </div>
                                    <div class="aging">
                                        <p>邮寄券</p>
                                        <span>有效期至：<?php echo date("Y-m-d",$value['end_time'])?></span>
                                    </div>
                                </div>
                                <div class="efficacy_bottom">
                                    <p>仅限于&nbsp;&nbsp;"邮寄快递"&nbsp;&nbsp;和&nbsp;&nbsp;"物流托运"&nbsp;&nbsp;时使用</p>
                                </div>
                            </div>
                            <?php
                        }
                    }
                }
                ?>
			</div>
		</div>
	</body>
	
	
	<script type="text/javascript" src="<?php echo IMG_PATH ?>bdkd/js/jquery-1.11.0.js" ></script>
    <script type="text/javascript" src="<?php echo IMG_PATH ?>bdkd/js/rem.js" ></script>
    <script type="text/javascript">

        /*
        点击过期图片中的X号删除优惠券
         */
        //获取优惠券id
        $(".omit img").on("click",function(){
            var vid=$(".vid").val();
            alert(vid);
            $.ajax({
                // 请求发送方式
                type: 'post',
                // 验证文件
                url: '<?php echo SITE_PATH ?>work/buser/delVoucher',
                dataType:'json',
                // 用户输入的帐号验证码
                data: {
                    'id':vid
                },
                success: function(data){
                    console.log(data);
                    if(data.result==1){
                        alert('删除成功!');
                    }else {
                        alert('删除失败!');
                    }
                },
                error: function(){
                    alert('删除失败!');
                }

            })
        });


        var type=$("#type").val();
       // alert(type);
        var id=$("#id").val();
        var wtype=$("#wtype").val();
        if(type==1){//1从支付页面进来  只有从支付页面进来才会执行下边代码
            //获取折扣或者金额 并跳转到支付页面(传订单id 哪种类型的支付)
            if(wtype==2 || wtype==3){//2寄快递页面 3物流托运
                $(".stamp").on("click",function(){
                    var zhekou1= $(this).children().find(".num").children().eq(0).html();
                    //alert(zhekou1);

                        //alert(zhekou1);
                    console.log(zhekou1);
                    if(wtype==2){//寄快递页面
                        window.location.href = '<?php echo SITE_PATH ?>work/bpost/wxhpay?id='+id+'&zhekou='+zhekou1;
                    }else {//物流托运页面
                        window.location.href = '<?php echo SITE_PATH ?>work/bpost/wxtpay?id='+id+'&zhekou='+zhekou1;
                    }

                });
                $(".stamps").on("click",function(){//取快递页面
                    alert("代取券只能在代取快递付款时使用!"); return false;
                });
            }else {//1代取页面
                $(".stamp").on("click",function(){
                    alert("邮寄券只能在邮寄快递或物流托运时使用!");return false;

                });
                $(".stamps").on("click",function(){//取快递页面
                    var zhekou1= $(this).children().find(".num").children().eq(0).html();

                    alert(zhekou1);console.log(zhekou1);
                    window.location.href = '<?php echo SITE_PATH ?>work/bpost/wxqpay?id='+id+'&zhekou='+zhekou1;
                });
            }
        }

    </script>
</html>
